import {
  createInput,
  createSelect,
  createSlot,
  commonRules,
  createDate,
  createTextarea,
} from '@/components/DynamicForm/config'

export const pageConfig = () => {
  const formConfig = {
    labelWidth: '90px',
    inline: true,
    keyup: true,
    buttonAlign: 'right',
    isSearch: true,
    buttons: [
      { text: '搜索', type: 'primary', action: 'submit' },
      { text: '重置', action: 'reset' },
    ],
  }
  const formItems = [
    createInput('当事人名称', 'username', {
      placeholder: '请输入当事人名称',
      style: { width: '18vw' },
      props: {
        clearable: true,
      },
    }),
    createSelect('承办人', 'field1', {
      placeholder: '请选择承办人',
      style: { width: '18vw' },
      props: {
        clearable: true,
        options: [
          { value: '刘青天', label: '刘青天' },
          { value: '张三', label: '张三' },
          { value: '李四', label: '李四' },
        ],
      },
    }),
    createSlot('立案时间', 'dateRange1', {
      placeholder: '请选择时间',
      style: { width: '18vw' },
    }),
    createSlot('结案时间', 'dateRange2', {
      placeholder: '请选择时间',
      style: { width: '18vw' },
    }),
  ]

  const formConfigBorrow = {
    labelWidth: '100px',
    keyup: true,
    buttonAlign: 'right',
    buttons: [],
  }
  const formItemsDetail = [
    createSlot('借阅时间', 'dateRange', {
      placeholder: '请选择借阅时间',
      style: { width: '100%' },
      span: 24,
      rules: [commonRules.required('借阅时间不能为空')],
    }),
    createInput('案卷号', 'field1', {
      placeholder: '请输入案卷号',
      style: { width: '100%' },
      span: 24,
      props: {
        clearable: true,
        formTitleTwo: '案卷信息',
      },
      rules: [commonRules.required('案卷号不能为空')],
    }),
    createInput('当事人名称', 'field2', {
      placeholder: '请输入当事人名称',
      style: { width: '100%' },
      span: 24,
      props: {
        clearable: true,
      },
      rules: [commonRules.required('当事人名称不能为空')],
    }),
    createInput('案由', 'field3', {
      placeholder: '请输入案由',
      style: { width: '100%' },
      span: 24,
      props: {
        clearable: true,
      },
      rules: [commonRules.required('案由不能为空')],
    }),
    createSlot('所属年份', 'year', {
      placeholder: '请选择所属年份',
      style: { width: '100%' },
      span: 24,
      props: {
        clearable: true,
      },
      rules: [commonRules.required('所属年份不能为空')],
    }),
    createInput('执法分队', 'field4', {
      placeholder: '请输入执法分队',
      style: { width: '100%' },
      span: 24,
      props: {
        clearable: true,
      },
      rules: [commonRules.required('执法分队不能为空')],
    }),
  ]

  const formConfigDetail = {
    labelWidth: '100px',
    keyup: true,
    buttonAlign: 'right',
    buttons: [],
  }
  const formDetailItems = [
    createSelect('案件来源', 'caseSource', {
      dictKey: 'case_source',
      props: {
        formTitle: '案卷基本信息',
      },
      span: 12,
      rules: [commonRules.required('案件来源不能为空')],
    }),
    createSlot('立案号', 'caseId', {
      placeholder: '请选择立案号',
      style: { width: '100%' },
      span: 12,
      rules: [commonRules.required('立案号不能为空')],
    }),
    createInput('当事人姓名', 'field1', {
      placeholder: '请输入当事人姓名',
      style: { width: '100%' },
      span: 12,
      props: {
        clearable: true,
      },
      rules: [commonRules.required('当事人姓名不能为空')],
    }),
    createInput('法定代表人/负责人/经营者', 'field2', {
      placeholder: '请输入法定代表人/负责人/经营者',
      style: { width: '100%' },
      span: 12,
      props: {
        clearable: true,
        longLabel: true,
      },
      rules: [commonRules.required('法定代表人/负责人/经营者不能为空')],
    }),
    createInput('统一社会信用代码/身份证号码', 'field3', {
      placeholder: '请输入统一社会信用代码/身份证号码',
      style: { width: '100%' },
      span: 12,
      props: {
        clearable: true,
        longLabel: true,
      },
      rules: [commonRules.required('统一社会信用代码/身份证号码不能为空')],
    }),
    createInput('地址', 'field4', {
      placeholder: '请输入地址',
      style: { width: '100%' },
      span: 24,
      props: {
        clearable: true,
      },
      rules: [commonRules.required('地址不能为空')],
    }),
    createTextarea('案由', 'caseCause', {
      placeholder: '请输入案由',
      style: { width: '100%' },
      span: 24,
      props: {
        clearable: true,
      },
      rules: [commonRules.required('案由不能为空')],
    }),
  ]

  const newColumns = [
    {
      label: '借阅人',
      key: 'field1',
      prop: 'field1',
      align: 'center' as const,
    },
    {
      label: '开始时间',
      key: 'field2',
      prop: 'field2',
      align: 'center' as const,
    },
    {
      label: '结束时间',
      key: 'field3',
      prop: 'field3',
      align: 'center' as const,
    },
    {
      label: '借阅时间',
      key: 'dateRange',
      prop: 'dateRange',
      align: 'center' as const,
    },
  ]

  return {
    formConfig,
    formItems,
    formConfigBorrow,
    formItemsDetail,
    formConfigDetail,
    formDetailItems,
    newColumns,
  }
}
